package io.renren.modules.brand.controller;

import java.util.Arrays;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.brand.entity.CarBrandEntity;
import io.renren.modules.brand.service.CarBrandService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author starry
 * @email starry@stu.hnucm.edu.cn
 * @date 2022-12-15 18:05:55
 */
@RestController
@RequestMapping("brand/carbrand")
@Api(tags = "汽车品牌Api")
public class CarBrandController {
    @Autowired
    private CarBrandService carBrandService;
    /**
     * 列表
     */
    @RequestMapping(value = "/list",method = RequestMethod.GET)
//    @RequiresPermissions("brand:carbrand:list")
    @ApiOperation("汽车品牌列表")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = carBrandService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping(value = "/info/{id}",method = RequestMethod.GET)
//    @RequiresPermissions("brand:carbrand:info")
    @ApiOperation("汽车品牌列表By id")
    public R info(@PathVariable("id") Integer id){
		CarBrandEntity carBrand = carBrandService.getById(id);

        return R.ok().put("carBrand", carBrand);
    }

    /**
     * 保存
     */
    @RequestMapping(value = "/save",method = RequestMethod.POST)
//    @RequiresPermissions("brand:carbrand:save")
    @ApiOperation("保存汽车")
    public R save(@RequestBody CarBrandEntity carBrand){
		carBrandService.save(carBrand);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update",method = RequestMethod.POST)
//    @RequiresPermissions("brand:carbrand:update")
    @ApiOperation("修改汽车")
    public R update(@RequestBody CarBrandEntity carBrand){
		carBrandService.updateById(carBrand);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete",method = RequestMethod.GET)
//    @RequiresPermissions("brand:carbrand:delete")
    @ApiOperation("删除汽车")
    public R delete(@RequestBody Integer[] ids){
		carBrandService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }
}
